package com.newcapec.lesson2;

import com.newcapec.lesson1.Student;

import java.util.Objects;

public class Car {
    private String color;
    private String number;

    public Car() {
    }

    public Car(String color, String number) {
        this.color = color;
        this.number = number;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    @Override
    public boolean equals(Object o) {
        // == 比较的是字面量
        if (this == o) {
            return true;
        }
        //此时地址不一样，需要查看内容是否一致
        if (o instanceof Car) {
            //判断具体内容
            Car car = (Car) o;
            if(super.equals(car) && this.color.equals(car.color)&& this.number.equals(car.getNumber())){
                return true;
            }
        }
        return false;
    }


    @Override
    public int hashCode() {
        return Objects.hash(color, number);
    }

    @Override
    public String toString() {
        return "Car{" +
                "color='" + color + '\'' +
                ", number='" + number + '\'' +
                '}';
    }
}
